package com.pokermind.model.po;

import java.math.BigDecimal;

/**
 * 扑克用户实体类 对应 poker_users 表
 *
 * @author PokerMind Team
 */
public class PokerUser {

    /** 主键ID */
    private Long id;

    /** 前端玩家ID（唯一标识符，如 mp_player_004） */
    private String playerId;

    /** 前端玩家显示名称（如 MiddlePosition，可为空） */
    private String playerName;

    /** 总手数 */
    private Integer totalHands;

    /** 总盈利 */
    private BigDecimal totalProfit;

    /** 创建时间戳(毫秒) */
    private Long createTime;

    /** 更新时间戳(毫秒) */
    private Long updateTime;

    // 德州扑克行为数据（简化）
    /** VPIP - 入池率 */
    private BigDecimal vpipRate;

    /** 进攻性水平 */
    private String aggressionLevel;

    /** 胜率 */
    private BigDecimal winRate;

    /** 玩牌风格 */
    private String playingStyle;

    /** 最近状态 */
    private String recentForm;

    // 默认构造函数
    public PokerUser() {
        this.totalHands = 0;
        this.totalProfit = BigDecimal.ZERO;
    }

    // 业务构造函数
    public PokerUser(String playerId, String playerName) {
        this();
        this.playerId = playerId;
        this.playerName = playerName;
        this.createTime = System.currentTimeMillis();
        this.updateTime = System.currentTimeMillis();
    }

    // 简化构造函数（只有playerId）
    public PokerUser(String playerId) {
        this(playerId, null);
    }

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPlayerId() {
        return playerId;
    }

    public void setPlayerId(String playerId) {
        this.playerId = playerId;
    }

    public String getPlayerName() {
        return playerName;
    }

    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

    public Integer getTotalHands() {
        return totalHands;
    }

    public void setTotalHands(Integer totalHands) {
        this.totalHands = totalHands;
    }

    public BigDecimal getTotalProfit() {
        return totalProfit;
    }

    public void setTotalProfit(BigDecimal totalProfit) {
        this.totalProfit = totalProfit;
    }

    // 业务方法

    /**
     * 更新统计信息
     */
    public void updateStats(BigDecimal profit) {
        this.totalHands = (this.totalHands == null ? 0 : this.totalHands) + 1;
        this.totalProfit = (this.totalProfit == null ? BigDecimal.ZERO : this.totalProfit).add(profit);
        this.updateTime = System.currentTimeMillis();
    }

    // 德州扑克行为数据的Getters and Setters
    public BigDecimal getVpipRate() {
        return vpipRate;
    }

    public void setVpipRate(BigDecimal vpipRate) {
        this.vpipRate = vpipRate;
    }

    public String getAggressionLevel() {
        return aggressionLevel;
    }

    public void setAggressionLevel(String aggressionLevel) {
        this.aggressionLevel = aggressionLevel;
    }

    public BigDecimal getWinRate() {
        return winRate;
    }

    public void setWinRate(BigDecimal winRate) {
        this.winRate = winRate;
    }

    public String getPlayingStyle() {
        return playingStyle;
    }

    public void setPlayingStyle(String playingStyle) {
        this.playingStyle = playingStyle;
    }

    public String getRecentForm() {
        return recentForm;
    }

    public void setRecentForm(String recentForm) {
        this.recentForm = recentForm;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * 更新行为数据
     */
    public void updateBehaviorData(BigDecimal vpipRate, String aggressionLevel, BigDecimal winRate, String playingStyle,
        String recentForm) {
        this.vpipRate = vpipRate;
        this.aggressionLevel = aggressionLevel;
        this.winRate = winRate;
        this.playingStyle = playingStyle;
        this.recentForm = recentForm;
        this.updateTime = System.currentTimeMillis();
    }

    /**
     * 判断行为数据是否可靠
     */
    public boolean isBehaviorDataReliable() {
        return this.totalHands != null && this.totalHands >= 50;
    }

    @Override
    public String toString() {
        return "PokerUser{" + "id=" + id + ", playerId='" + playerId + '\'' + ", playerName='" + playerName + '\'' + ", totalHands=" + totalHands + ", totalProfit=" + totalProfit + ", vpipRate=" + vpipRate + ", playingStyle='" + playingStyle + '\'' + ", recentForm='" + recentForm + '\'' + '}';
    }
}